<%@ Page Language="C#" MasterPageFile="~/SurveyHost.Master" AutoEventWireup="true"
    CodeBehind="Configuration.aspx.cs" Inherits="SurveyHost.Web.Admin.Configuration"
    Title="Configuration" %>

<%@ Import Namespace="SurveyHost.Core" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="post">
        <h1 class="title">
            survey configuration
        </h1>
        <p class="byline">
            Edit various configuration settings for the survey
        </p>
        <div class="entry">
            <asp:FormView ID="FormView1" Width="100%" runat="server" 
                DataSourceID="ObjectDataSource1">
                <EditItemTemplate>
                    <div>
                        Survey Name:<br />
                        <asp:TextBox ID="SurveyNameTextBox" runat="server" Text='<%# Bind("SurveyName") %>'
                            ToolTip="The name of the survey" Width="80%" />&nbsp;
                        <asp:RequiredFieldValidator runat="server" ControlToValidate="SurveyNameTextBox">Required</asp:RequiredFieldValidator>
                    </div>
                    <div>
                        Administrator Name:<br />
                        <asp:TextBox ID="AdministratorNameTextBox" runat="server" Text='<%# Bind("AdministratorName") %>'
                            ToolTip="The name to use for the administrator in survey emails" Width="80%" />
                        &nbsp;
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="AdministratorNameTextBox">Required</asp:RequiredFieldValidator>
                    </div>
                    <p>
                        The following tokens can be used for the invitation and survey complete emails (they
                        will be replaced by the real values when sending):
                        <ul>
                            <li>
                                <%= ConfigurationHelper.WEBSITETOKEN %>
                                -- the address to the survey website</li>
                            <li>
                                <%= ConfigurationHelper.USERNAMETOKEN %>
                                -- the user&#39;s login name</li>
                            <li>
                                <%= ConfigurationHelper.PASSWORDTOKEN %>
                                -- the user&#39;s login password</li>
                            <li>
                                <%= ConfigurationHelper.FINISHTIMETOKEN %>
                                -- the date and time the user finished the survey</li>
                            <li>
                                <%= ConfigurationHelper.ADMINEMAILTOKEN %>
                                -- the administrator&#39;s public email</li>
                            <li>
                                <%= ConfigurationHelper.CONFIRMATIONNUMBERTOKEN %>
                                -- the confirmation number used to verify a person has completed the survey</li>
                            <li>
                                <%= ConfigurationHelper.GIVENNAMETOKEN %>
                                -- the name given by the participant when submitting to the terms of the survey</li>
                            <li>
                                <%= ConfigurationHelper.USEREMAILTOKEN %>
                                -- the email address used to send the user their confirmation email address</li>
                        </ul>
                    </p>
                    <div>
                        Invitation Email:<br />
                        <asp:TextBox Rows="5" ID="InvitationEmailTextBox" runat="server" Text='<%# Bind("InvitationEmail") %>'
                            ToolTip="The body of the the invitation email" Width="80%" TextMode="MultiLine" />
                        &nbsp;
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="InvitationEmailTextBox">Required</asp:RequiredFieldValidator>
                    </div>
                    <div>
                        Completion Email:<br />
                        <asp:TextBox Rows="5" ID="CompletionEmailTextBox" runat="server" Text='<%# Bind("CompletionEmail") %>'
                            ToolTip="The body of the survey complete email" Width="80%" TextMode="MultiLine" />
                        &nbsp;
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="CompletionEmailTextBox">Required</asp:RequiredFieldValidator>
                    </div>
                    <div>
                        Administrator Public Email:<br />
                        <asp:TextBox ID="AdministratorPublicEmailTextBox" runat="server" Width="80%" Text='<%# Bind("AdministratorPublicEmail") %>'
                            ToolTip="The email address to use in public communications" />
                    </div>
                    <div>
                        Administrator Private Email:<br />
                        <asp:TextBox ID="AdministratorPrivateEmailTextBox" runat="server" Width="80%" Text='<%# Bind("AdministratorPrivateEmail") %>'
                            ToolTip="The email address to use for private communications" />
                    </div>
                    <div>
                        <asp:CheckBox ID="ScreenApplicantCheckBox" runat="server" Checked='<%# Bind("ScreenApplicant") %>'
                            ToolTip="When checked, performs applicant screening" Text="Perform Applicant Screening" />
                    </div>
                    <div>
                        Email Host Name or IP Address:<br />
                        <asp:TextBox ID="SMTPHostTextBox" runat="server" Text='<%# Bind("SMTPHost") %>' ToolTip="The IP or name of the email server (SMTP) to use for sending mail" />
                    </div>
                    <div style="vertical-align: middle;">
                        Email Host Port:&nbsp;
                        <asp:TextBox ID="SMTPPortTextBox" runat="server" Text='<%# Bind("SMTPPort") %>' ToolTip="The port of the SMTP server to use" />&nbsp;
                        <asp:RegularExpressionValidator runat="server" ControlToValidate="SMTPPortTextBox"
                            Text="Invalid number" ValidationExpression="0|[1-9]\d*" />
                    </div>
                    <div>
                        Email Host Login Name:<br />
                        <asp:TextBox ID="SMTPLoginNameTextBox" Width="80%" runat="server" Text='<%# Bind("SMTPLoginName") %>'
                            ToolTip="The login name for the email server" />
                    </div>
                    <div>
                        Email Host Login Password:<br />
                        <asp:TextBox ID="SMTPLoginPasswordTextBox" Width="80%" runat="server" Text='<%# Bind("SMTPLoginPassword") %>'
                            ToolTip="The login email for the email server" />
                    </div>
                    <div>
                        Email Host Requires SSL:&nbsp;
                        <asp:CheckBox ID="SMTPUseSSLCheckBox" runat="server" Checked='<%# Bind("SMTPUseSSL") %>'
                            ToolTip="If checked, uses SSL to connect with the email server" />
                    </div>
                    <div style="text-align: right;">
                        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                            Text="Update" />
                        &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
                            CommandName="Cancel" Text="Cancel" /></div>
                </EditItemTemplate>
                <InsertItemTemplate>
                    Hello. You&#39;re seeing this in error. My apologies.
                </InsertItemTemplate>
                <ItemTemplate>
                    <p>
                        Survey Name:&nbsp;<asp:Label ID="snlabel" runat="server" Text='<%# Bind("SurveyName") %>' />
                    </p>
                    <p>
                        Administrator Name:&nbsp;<asp:Label ID="Label2" runat="server" Text='<%# Bind("AdministratorName") %>' />
                    </p>
                    <p>
                        Invitation Email:<br />
                        <asp:TextBox Rows="5" ID="TextBox1" runat="server" Text='<%# Bind("InvitationEmail") %>'
                            Width="80%" TextMode="MultiLine" ReadOnly="true" />
                    </p>
                    <p>
                        Completion Email:<br />
                        <asp:TextBox Rows="5" ID="CompletionEmailTextBox" runat="server" Text='<%# Bind("CompletionEmail") %>'
                            Width="80%" TextMode="MultiLine" ReadOnly="true" />
                    </p>
                    <p>
                        Administrator Public Email:&nbsp;<asp:Label ID="Label3" runat="server" Text='<%# Bind("AdministratorPublicEmail") %>' />
                    </p>
                    <p>
                        Administrator Private Email:&nbsp;<asp:Label ID="Label4" runat="server" Text='<%# Bind("AdministratorPrivateEmail") %>' />
                    </p>
                    <p>Screen applicants:&nbsp;<asp:Label ID="Label1" runat="server" Text='<%# Bind("ScreenApplicant") %>' />
                    </p>
                    <p>
                        Email Host Name or IP Address:&nbsp;<asp:Label ID="Label5" runat="server" Text='<%# Bind("SMTPHost") %>' />
                    </p>
                    <p>
                        Email Host Port:&nbsp;<asp:Label ID="Label6" runat="server" Text='<%# Bind("SMTPPort") %>' />
                    </p>
                    <p>
                        Email Host Login Name:&nbsp;<asp:Label ID="Label7" runat="server" Text='<%# Bind("SMTPLoginName") %>' />
                    </p>
                    <p>
                        Email Host Login Password:&nbsp;<asp:Label ID="Label8" runat="server" Text='<%# Bind("SMTPLoginPassword") %>' />
                    </p>
                    <p>
                        Email Host Requires SSL:&nbsp;<asp:Label ID="Label9" runat="server" Text='<%# Bind("SMTPUseSSL") %>' />
                    </p>
                    <p style="text-align: right;">
                        <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                            Text="Edit" />
                    </p>
                </ItemTemplate>
            </asp:FormView>
        </div>
    </div>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete"
        InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="FetchConfiguration"
        TypeName="SurveyHost.Core.DAL.HostConfigurationController" UpdateMethod="UpdateConfiguration"
        DataObjectTypeName="SurveyHost.Core.DAL.HostConfiguration" ConvertNullToDBNull="True">
        <DeleteParameters>
            <asp:Parameter Name="HostName" Type="Object" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="HostName" Type="String" />
            <asp:Parameter Name="SurveyName" Type="String" />
            <asp:Parameter Name="AdministratorName" Type="String" />
            <asp:Parameter Name="InvitationEmail" Type="String" />
            <asp:Parameter Name="CompletionEmail" Type="String" />
            <asp:Parameter Name="AdministratorPublicEmail" Type="String" ConvertEmptyStringToNull="true" />
            <asp:Parameter Name="AdministratorPrivateEmail" Type="String" ConvertEmptyStringToNull="true" />
            <asp:Parameter Name="ScreenApplicant" Type="Boolean" />
            <asp:Parameter Name="SMTPHost" Type="String" ConvertEmptyStringToNull="true" />
            <asp:Parameter Name="SMTPPort" Type="Int32" ConvertEmptyStringToNull="true" />
            <asp:Parameter Name="SMTPLoginName" Type="String" ConvertEmptyStringToNull="true" />
            <asp:Parameter Name="SMTPLoginPassword" Type="String" ConvertEmptyStringToNull="true" />
            <asp:Parameter Name="SMTPUseSSL" Type="Boolean" />
        </InsertParameters>
    </asp:ObjectDataSource>
</asp:Content>
